import 'package:app_admin/extension/custom_ext.dart';
import 'package:app_admin/pages/orderSetAdd/orderSet_add_logic.dart';
import 'package:app_admin/res/images.dart';
import 'package:app_admin/res/styles.dart';
import 'package:app_admin/widgets/title_bar.dart';
import 'package:app_admin/widgets/touch_close_keyboard.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class OrderSetAddPage extends StatelessWidget {
  final logic = Get.find<OrderSetAddLogic>();

  OrderSetAddPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Obx(() => Scaffold(
        appBar: TitleBar.backAndSave(
          title: logic.titleName.value,
          backgroundColor: Styles.c_0089FF,
          onAddFun: () => {logic.btnSave(context)},
        ),
        backgroundColor: Styles.c_F8F9FA,
        body: TouchCloseSoftKeyboard(
          isGradientBg: true,
          child: SingleChildScrollView(
              child: Column(
            children: [
              50.verticalSpace,
              Row(children: [
                Container(
                  width: 100.w,
                  alignment: Alignment.centerRight,
                  child: "设置订货日期:".toText..style = Styles.ts_0C1C33_12sp,
                ),
                30.horizontalSpace,
                GestureDetector(
                    behavior: HitTestBehavior.translucent,
                    onTap: logic.openDatePicker,
                    child: Container(
                      height: 42.h,
                      width: 200.w,
                      padding: EdgeInsets.only(left: 12.w, right: 8.w),
                      decoration: BoxDecoration(
                        border: Border.all(color: Styles.c_E8EAEF, width: 1),
                        borderRadius: BorderRadius.circular(8.r),
                      ),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Expanded(
                            child: logic.time.value.toText
                              ..style = Styles.ts_0C1C33_12sp,
                          ),
                          ImageRes.calendar.toImage
                            ..width = 24.w
                            ..height = 24.h,
                        ],
                      ),
                    )),
              ]),
              20.verticalSpace,
              Row(children: [
                Container(
                  width: 100.w,
                  alignment: Alignment.centerRight,
                  child: "订货商名称:".toText..style = Styles.ts_0C1C33_12sp,
                ),
                30.horizontalSpace,
                GestureDetector(
                    behavior: HitTestBehavior.translucent,
                    onTap: () => {logic.openOrderPlayerSelect(context)},
                    child: Container(
                      height: 42.h,
                      width: 200.w,
                      padding: EdgeInsets.only(left: 12.w, right: 8.w),
                      decoration: BoxDecoration(
                        border: Border.all(color: Styles.c_E8EAEF, width: 1),
                        borderRadius: BorderRadius.circular(8.r),
                      ),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Expanded(
                            child: logic.orderPlayer.value.toText
                              ..style = Styles.ts_0C1C33_12sp,
                          ),
                          ImageRes.downArrow.toImage
                            ..width = 24.w
                            ..height = 24.h,
                        ],
                      ),
                    )),
              ]),
              20.verticalSpace,
              Row(children: [
                Container(
                  width: 100.w,
                  alignment: Alignment.centerRight,
                  child: "物料名称:".toText..style = Styles.ts_0C1C33_12sp,
                ),
                30.horizontalSpace,
                GestureDetector(
                    behavior: HitTestBehavior.translucent,
                    onTap: () => {logic.openOrderGoodsSelect(context)},
                    child: Container(
                      height: 42.h,
                      width: 200.w,
                      padding: EdgeInsets.only(left: 12.w, right: 8.w),
                      decoration: BoxDecoration(
                        border: Border.all(color: Styles.c_E8EAEF, width: 1),
                        borderRadius: BorderRadius.circular(8.r),
                      ),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Expanded(
                            child: logic.orderGoods.value.toText
                              ..style = Styles.ts_0C1C33_12sp,
                          ),
                          ImageRes.downArrow.toImage
                            ..width = 24.w
                            ..height = 24.h,
                        ],
                      ),
                    )),
              ]),
              20.verticalSpace,
              Row(children: [
                Container(
                  width: 100.w,
                  alignment: Alignment.centerRight,
                  child: "品味规格:".toText..style = Styles.ts_0C1C33_12sp,
                ),
                30.horizontalSpace,
                GestureDetector(
                    behavior: HitTestBehavior.translucent,
                    onTap: () => {logic.openOrderLevelSelect(context)},
                    child: Container(
                      height: 42.h,
                      width: 200.w,
                      padding: EdgeInsets.only(left: 12.w, right: 8.w),
                      decoration: BoxDecoration(
                        border: Border.all(color: Styles.c_E8EAEF, width: 1),
                        borderRadius: BorderRadius.circular(8.r),
                      ),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Expanded(
                            child: logic.orderLevel.value.toText
                              ..style = Styles.ts_0C1C33_12sp,
                          ),
                          ImageRes.downArrow.toImage
                            ..width = 24.w
                            ..height = 24.h,
                        ],
                      ),
                    )),
              ]),
              20.verticalSpace,
              Row(children: [
                Container(
                  width: 100.w,
                  alignment: Alignment.centerRight,
                  child: "单价:".toText..style = Styles.ts_0C1C33_12sp,
                ),
                30.horizontalSpace,
                Container(
                    height: 42.h,
                    width: 200.w,
                    padding: EdgeInsets.only(left: 12.w, right: 8.w),
                    decoration: BoxDecoration(
                      border: Border.all(color: Styles.c_E8EAEF, width: 1),
                      borderRadius: BorderRadius.circular(8.r),
                    ),
                    child: TextField(
                      controller: logic.priceCtrl,
                      keyboardType: TextInputType.number,
                      textInputAction: TextInputAction.next,
                      style: Styles.ts_0C1C33_12sp,
                      decoration: InputDecoration(
                        hintStyle: Styles.ts_0C1C33_12sp,
                        isDense: true,
                        border: InputBorder.none,
                      ),
                    ))
              ]),
              20.verticalSpace,
              Row(children: [
                Container(
                  width: 100.w,
                  alignment: Alignment.centerRight,
                  child: "总价:".toText..style = Styles.ts_0C1C33_12sp,
                ),
                30.horizontalSpace,
                Container(
                    height: 42.h,
                    width: 200.w,
                    padding: EdgeInsets.only(left: 12.w, right: 8.w),
                    decoration: BoxDecoration(
                      border: Border.all(color: Styles.c_E8EAEF, width: 1),
                      borderRadius: BorderRadius.circular(8.r),
                    ),
                    child: TextField(
                      controller: logic.totalpriceCtrl,
                      keyboardType: TextInputType.number,
                      textInputAction: TextInputAction.next,
                      style: Styles.ts_0C1C33_12sp,
                      decoration: InputDecoration(
                        hintStyle: Styles.ts_0C1C33_12sp,
                        isDense: true,
                        border: InputBorder.none,
                      ),
                    ))
              ]),
              20.verticalSpace,
              Row(children: [
                Container(
                  width: 100.w,
                  alignment: Alignment.centerRight,
                  child: "订货量:".toText..style = Styles.ts_0C1C33_12sp,
                ),
                30.horizontalSpace,
                Container(
                    height: 42.h,
                    width: 200.w,
                    padding: EdgeInsets.only(left: 12.w, right: 8.w),
                    decoration: BoxDecoration(
                      border: Border.all(color: Styles.c_E8EAEF, width: 1),
                      borderRadius: BorderRadius.circular(8.r),
                    ),
                    child: TextField(
                      controller: logic.numCtrl,
                      keyboardType: TextInputType.number,
                      textInputAction: TextInputAction.next,
                      style: Styles.ts_0C1C33_12sp,
                      decoration: InputDecoration(
                        hintStyle: Styles.ts_0C1C33_12sp,
                        isDense: true,
                        border: InputBorder.none,
                      ),
                    ))
              ])
            ],
          )),
        )));
  }
}
